//
//  XZBaseTool.m
//  洲帅微博
//
//  Created by lixiangzhou on 14-7-16.
//  Copyright (c) 2014年 lxz. All rights reserved.
//

#import "XZBaseTool.h"
#import "XZHttpTool.h"
#import "MJExtension.h"

@implementation XZBaseTool

+ (void)getWithUrl:(NSString *)url parameter:(id)parameter resultClass:(Class)resultClass success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    NSDictionary *dictParam = [parameter keyValues];
    
    [XZHttpTool getWithUrl:url parameters:dictParam success:^(id responseObj) {
        id resultObj = [resultClass objectWithKeyValues:responseObj];
        if (success) {
            success(resultObj);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)postWithUrl:(NSString *)url parameter:(id)parameter resultClass:(Class)resultClass success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    NSDictionary *dictParam = [parameter keyValues];
    
    [XZHttpTool postWithUrl:url parameters:dictParam success:^(id responseObj) {
        id resultObj = [resultClass objectWithKeyValues:responseObj];
        if (success) {
            success(resultObj);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

@end
